<script setup>
import { useRoute } from 'vue-router'
import { onMounted, ref } from 'vue'
import axios from 'axios'
import router from '../router/router'
const route = useRoute()
const id = ref(route.query.id)
const article = ref([])

const goBack = () => {
  router.push('/articleList')
}
const handleDelete = (i, item) => {
  article.value.splice(i, 1)
  axios.get('/api/mycontroller4/mymethod4/' + id.value).then((res) => {

  })
  console.log(article)
}

onMounted(() => {
  axios.get('/api/mycontroller3/mymethod3/' + id.value).then((res) => {
    article.value = res.data
    console.log(article.value)
  })
})

</script>

<template>

<div style="text-align: left;">
        <el-button type="text"  @click="goBack" style="padding-bottom: 0px;"><el-icon><Back /></el-icon>返回</el-button>
    </div>

  <el-table :data="article" style="width: 100%"
   :header-cell-style="{'text-align':'left'}"
      :cell-style="{'text-align':'left'}">
    <el-table-column prop="title" label="标题" width="400" />
    <el-table-column prop="edittime" label="编辑时间" width="330" />
    <el-table-column prop="cid" label="作者" width="250"/>
    <el-table-column align="right">
      <template #default="scope">
  <el-popconfirm
        confirm-button-text="是的"
         @confirm="handleDelete(scope.$index,scope.row)"
        cancel-button-text="取消"
        :icon="InfoFilled"
        icon-color="red"
          title="确定删除吗?">
 <template #reference>
      <el-button type="danger" size="small">删除
      </el-button>
  </template>
      </el-popconfirm>
      </template>
    </el-table-column>
  </el-table>
</template>

<style scoped>

</style>
